package com.example.a7822.myapplication.shopcart.beans;



import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by 洪坤峰 on 2017/5/31.
 */

public class ShopBean implements Serializable {
    /**
     * 店铺Logo
     */
    private String ImageUrl;
    /**
     * 店铺名称
     */
    private String ShopName;
    /**
     * 店铺ID
     */
    private int ShopId;
    /**
     * 店铺简介
     */
    private String ShopBrief;
    /**
     * 店铺图片
     */
    private String shopPicUrl;
    /**
     * 店铺详情
     */
    private String ShopDetail;
    /**
     * 店铺距离
     */
    private String ShopDistance;
    /**
     * 店铺评价
     */
    private int ShopRate;
    /**
     * 是否关注
     */
    private Boolean isFavorite;
    /**
     * 类型，设置为0
     */
    private int type;
//    private PinYin.PinYinElement pinyinElement = new PinYin.PinYinElement();
//    private SearchElement searchElement = new SearchElement();

    public String getImageUrl() {
        return ImageUrl;
    }

    public void setImageUrl(String imageUrl) {
        ImageUrl = imageUrl;
    }

    public String getShopName() {
        return ShopName;
    }

    public void setShopName(String shopName) {
        ShopName = shopName;
    }

    public int getShopId() {
        return ShopId;
    }

    public void setShopId(int shopId) {
        ShopId = shopId;
    }

    public String getShopBrief() {
        return ShopBrief;
    }

    public void setShopBrief(String shopBrief) {
        ShopBrief = shopBrief;
    }

    public String getShopPicUrl() {
        return shopPicUrl;
    }

    public void setShopPicUrl(String shopPicUrl) {
        this.shopPicUrl = shopPicUrl;
    }

    public String getShopDetail() {
        return ShopDetail;
    }

    public void setShopDetail(String shopDetail) {
        ShopDetail = shopDetail;
    }

    public String getShopDistance() {
        return ShopDistance;
    }

    public void setShopDistance(String shopDistance) {
        ShopDistance = shopDistance;
    }

    public int getShopRate() {
        return ShopRate;
    }

    public void setShopRate(int shopRate) {
        ShopRate = shopRate;
    }

    public Boolean getFavorite() {
        return isFavorite;
    }

    public void setFavorite(Boolean favorite) {
        isFavorite = favorite;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }
//    public PinYin.PinYinElement getPinyinElement() {
//        return pinyinElement;
//    }
//
//
//    public SearchElement getSearchElement() {
//        return searchElement;
//    }
    public String toString(){
        JSONObject shop = new JSONObject();
        try {
            shop.put("ImageUrl",ImageUrl+"");
            shop.put("ShopName",ShopName+"");
            shop.put("ShopId",ShopId);
            shop.put("ShopBrief",ShopBrief);
            shop.put("ShopDetail",ShopDetail+"");
            shop.put("ShopRate",ShopRate);
            shop.put("ShopDistance",ShopDistance+"");
            shop.put("isFavorite",isFavorite);
            shop.put("shopPicUrl", shopPicUrl + "");
        }catch (JSONException e){
            e.printStackTrace();
        }
        return shop.toString();
    }
    public static ShopBean fromString(String shop){
        ShopBean shopmodel = new ShopBean();
        try {
            JSONObject json = new JSONObject(shop);
            shopmodel.ImageUrl = json.getString("ImageUrl");
            shopmodel.ShopName = json.getString("ShopName");
            shopmodel.ShopId = json.getInt("ShopId");
            shopmodel.ShopBrief = json.getString("ShopBrief");
            shopmodel.ShopDetail = json.getString("ShopDetail");
            shopmodel.ShopDistance = json.getString("ShopDistance");
            shopmodel.isFavorite = json.getBoolean("isFavorite");
            shopmodel.ShopRate = json.getInt("ShopRate");
            shopmodel.shopPicUrl = json.getString("shopPicUrl");
        }catch (JSONException e){
            e.printStackTrace();
        }
        return shopmodel;
    }
}
